<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: holle
  Date: 2020/6/14
  Time: 10:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="utf-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title></title>
    <script>
		function xmTanUploadImg(obj) {
			var file = obj.files[0];
			var reader = new FileReader();
			reader.readAsDataURL(file);
			reader.onload = function (e) {    //成功读取文件
				var img = document.getElementById("selectImg");
				img.src = e.target.result;   //或 img.src = this.result / e.target == thi
			};
		}
    </script>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script type="text/javascript"
            src="<%=basePath%>static/js/jquery-1.12.4.min.js"></script>
    <link
            href="<%=basePath%>static/bootstrap-3.3.7-dist/css/bootstrap.min.css"
            rel="stylesheet">
    <script type="text/javascript"
            src="<%=basePath%>static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>My97DatePicker/WdatePicker.js"></script>
</head>
<body>

<c:if test="${requestScope.message !=null}">
    <br>
    <font color="red">${requestScope.message}</font>
    <br>
</c:if>
<center>
    <h2>添加图书</h2>
    <div style="width: 143px;height: 143px;">
        <img src="" id="selectImg" class="img-circle">
    </div>
    <p/>
    <form class="form-horizontal" role="form" style="width: 600px"
          action="book/addBook" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-sm-2 control-label">图书图片</label>
            <div class="col-sm-10">
                <input type="file" class="form-control"placeholder="" name="pic" id="uploadImg" onchange="xmTanUploadImg(this)">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">图书名字</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="firstname3" placeholder="请输入图书名" name="book_name">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">出版社</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="firstname" placeholder="请输入出版社" name="public_dept">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">图书价格</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="book_price" placeholder="请输入价格" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">出版日期</label>
            <div class="col-sm-10">
                <input type="text" class="form-control"placeholder="请输入出版日期" name="public_date" class="Wdate" onclick="WdatePicker()" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">作者</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="firstname1" placeholder="请输入作者" name="book_auth">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">简介</label>
            <div class="col-sm-12">
                <TEXTAREA name="summary" cols="40" rows="5"></TEXTAREA>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-default">添加</button>
            </div>
        </div>
    </form>
</center>
</body>
</html>

